package com.until.request;

import java.lang.reflect.Field;
import java.lang.reflect.Type;

/**
 * @author AdminUser
 */
public class ParamNotNull {
    /**
     * 判断自定义的对象是否是空值
     * @param object 传输的对象
     * @return 返回是否为空
     */
    public static boolean objCheckIsNull(Object object){
        if (object == null) {
            return true;
        }
        Class<?> clazz = object.getClass();
        Field[] fields = clazz.getDeclaredFields();
        boolean flag = true;
        for(Field field : fields){
            field.setAccessible(true);
            Object fieldValue = null;
            try {
                fieldValue = field.get(object);
                Type fieldType =field.getGenericType();
                String fieldName = field.getName();
                System.out.println("属性类型："+fieldType+",属性名："+fieldName+",属性值："+fieldValue);
            } catch (IllegalArgumentException | IllegalAccessException e) {
                e.printStackTrace();
            }
            if(fieldValue != null){
                flag = false;
                break;
            }
        }
        return flag;
    }


}
